package com.sba.core.web.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

/**
 * 
 * @author feiliming
 *
 */
public class ThemeInterceptor implements HandlerInterceptor {
	
	@Value("${ssh.admin-path}")
	protected String adminPath;
	
	@Value("${ssh.admin-theme-path}")
	protected String adminThemePath;

	//controller之前
	@Override
	public boolean preHandle(HttpServletRequest request,
			HttpServletResponse response, Object handler) throws Exception {
		//判断session是否有效
		return true;
	}

	//controller之后，返回视图之前
	@Override
	public void postHandle(HttpServletRequest request,
			HttpServletResponse response, Object handler,
			ModelAndView modelAndView) throws Exception {
		modelAndView.getModel().put("adminPath", adminPath);
		modelAndView.getModel().put("adminThemePath", adminThemePath);
	}

	//controller之后，返回视图之后，即请求结束之后，可以用来处理日志
	@Override
	public void afterCompletion(HttpServletRequest request,
			HttpServletResponse response, Object handler, Exception ex)
			throws Exception {
		// TODO Auto-generated method stub
		
	}

}
